<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */


/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 */
class Application_Model_Curso extends Application_Model_ModelAbstract
{

    /**
     * PK
     * Database var type int(10) unsigned
     *
     * @var int
     */
    protected $_CodigoCurso;

    /**
     * Database var type int(10) unsigned
     *
     * @var int
     */
    protected $_CodigoAreaAcademica;

    /**
     * Inicio
     * Database var type date
     *
     * @var string
     */
    protected $_FechaInicio;

    /**
     * Fin
     * Database var type date
     *
     * @var string
     */
    protected $_FechaFin;

    /**
     * Cantidad total de horas catedras
     * Database var type int(10) unsigned
     *
     * @var int
     */
    protected $_CantidadHoras;


    /**
     * Parent relation curso_ibfk_1
     *
     * @var Application_Model_AreaAcademica
     */
    protected $_AreaAcademica;
    
    /**
     * Parent relation curso_ibfk_1
     *
     * @var Application_Model_AreaAcademica
     */
    protected $_Nombre;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'codigo_curso'=>'CodigoCurso',
            'codigo_area_academica'=>'CodigoAreaAcademica',
            'fecha_inicio'=>'FechaInicio',
            'nombre'=>'Nombre',
            'fecha_fin'=>'FechaFin',
            'cantidad_horas'=>'CantidadHoras',
        ));

        $this->setParentList(array(
            'CursoIbfk1'=> array(
                    'property' => 'AreaAcademica',
                    'table_name' => 'AreaAcademica',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column codigo_curso
     *
     * @param int $data
     * @return Application_Model_Curso
     */
    public function setCodigoCurso($data)
    {
        $this->_CodigoCurso = $data;
        return $this;
    }
    
    /**
     * Sets column nombre
     *
     * @param int $data
     * @return Application_Model_Curso
     */
    public function setNombre($data)
    {
        $this->_Nombre = $data;
        return $this;
    }

    /**
     * Gets column codigo_curso
     *
     * @return int
     */
    public function getCodigoCurso()
    {
        return $this->_CodigoCurso;
    }

    /**
     * Sets column codigo_area_academica
     *
     * @param int $data
     * @return Application_Model_Curso
     */
    public function setCodigoAreaAcademica($data)
    {
        $this->_CodigoAreaAcademica = $data;
        return $this;
    }

    /**
     * Gets column codigo_area_academica
     *
     * @return int
     */
    public function getCodigoAreaAcademica()
    {
        return $this->_CodigoAreaAcademica;
    }
    
    /**
     * Gets column nombre
     *
     * @return int
     */
    public function getNombre()
    {
        return $this->_Nombre;
    }

    /**
     * Sets column fecha_inicio
     *
     * @param string $data
     * @return Application_Model_Curso
     */
    public function setFechaInicio($data)
    {
        $this->_FechaInicio = $data;
        return $this;
    }

    /**
     * Gets column fecha_inicio
     *
     * @return string
     */
    public function getFechaInicio()
    {
        return $this->_FechaInicio;
    }

    /**
     * Sets column fecha_fin
     *
     * @param string $data
     * @return Application_Model_Curso
     */
    public function setFechaFin($data)
    {
        $this->_FechaFin = $data;
        return $this;
    }

    /**
     * Gets column fecha_fin
     *
     * @return string
     */
    public function getFechaFin()
    {
        return $this->_FechaFin;
    }

    /**
     * Sets column cantidad_horas
     *
     * @param int $data
     * @return Application_Model_Curso
     */
    public function setCantidadHoras($data)
    {
        $this->_CantidadHoras = $data;
        return $this;
    }

    /**
     * Gets column cantidad_horas
     *
     * @return int
     */
    public function getCantidadHoras()
    {
        return $this->_CantidadHoras;
    }

    /**
     * Sets parent relation CodigoAreaAcademica
     *
     * @param Application_Model_AreaAcademica $data
     * @return Application_Model_Curso
     */
    public function setAreaAcademica(Application_Model_AreaAcademica $data)
    {
        $this->_AreaAcademica = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['codigo_area_academica'];
        }

        $this->setCodigoAreaAcademica($primary_key);

        return $this;
    }

    /**
     * Gets parent CodigoAreaAcademica
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_AreaAcademica
     */
    public function getAreaAcademica($load = true)
    {
        if ($this->_AreaAcademica === null && $load) {
            $this->getMapper()->loadRelated('CursoIbfk1', $this);
        }

        return $this->_AreaAcademica;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Curso
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Curso());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Curso::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getCodigoCurso() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('codigo_curso = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getCodigoCurso()));
    }
}
